package view.pieces;

import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.geom.Rectangle2D;
import java.util.Observable;

import javax.swing.ImageIcon;

import resources.GlobalSettings;
import resources.ImageBundle;

import model.pieces.Man;

public class ManDisplayView extends PieceDisplayView {

	private static final Image manImage = new ImageIcon(ImageBundle.get("man_" + GlobalSettings.pieceImageWidth)).getImage();
	
	public ManDisplayView(Graphics2D g2d, Man man) {
		super(g2d, man);
		this.oldPiece = new Man(man.getCol(), man.getRow());
	}

	@Override
	public void paint(Graphics2D g2D) {
		this.g2D = g2D;
		
		clearOldPiece();
		this.oldPiece = new Man(piece.getCol(), piece.getRow());
		
		Rectangle2D rect = getPieceRectangle();
		
		this.g2D.setColor(GlobalSettings.levelPanelColor);
		this.g2D.fill(rect);
		this.g2D.setColor(GlobalSettings.levelPanelColor);
		this.g2D.draw(rect);

		this.g2D.drawImage(manImage,
				(int) rect.getMinX(), (int) rect.getMinY(), (int) rect.getMaxX(), (int) rect.getMaxY(),
				0, 0, GlobalSettings.pieceImageWidth, GlobalSettings.pieceImageHeight,
				null);
		/*
		//hombre
		Color Cabeza=new Color(255, 196, 196);//164,82,0
		Color Cuerpo=new Color(0, 81, 0);//164,82,0
		Color Pie=new Color(154,174,13);//164,82,0
		//cabeza
		this.g2D.setColor(Cabeza);
		this.g2D.fillArc((int)rect.getX()+16, (int)rect.getY()+1,10 ,15, 0, 360);
	    this.g2D.setColor(Color.black);
	    this.g2D.drawArc((int)rect.getX()+16, (int)rect.getY()+1,10 ,15, 0, 360);
	    //cuerpo
	    this.g2D.setColor(Cuerpo);
		this.g2D.fill3DRect((int)rect.getX()+12,(int)rect.getY()+13, 18, 22,true);
		this.g2D.setColor(Color.black);
		this.g2D.draw3DRect((int)rect.getX()+12,(int)rect.getY()+13,18,22,true);
		//pie1
		this.g2D.setColor(Pie);
		this.g2D.fillRect((int)rect.getX()+7,(int)rect.getY()+36, 12, 3);
		this.g2D.setColor(Color.black);
		this.g2D.drawRect((int)rect.getX()+7,(int)rect.getY()+36,12,3);
		//pie2
		this.g2D.setColor(Pie);
		this.g2D.fillRect((int)rect.getX()+20,(int)rect.getY()+36, 12, 3);
		this.g2D.setColor(Color.black);
		this.g2D.drawRect((int)rect.getX()+20,(int)rect.getY()+36,12,3);
		//nombre
		this.g2D.setColor(Color.BLACK);
		this.g2D.drawString("M",(int)rect.getX()+17,(int)rect.getY()+26);
		*/
	}

	@Override
	public void update(Observable o, Object arg) {
		this.paint(this.g2D);
	}

}